package com.loyi.ams.gateway.hbmis.dao;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.loyi.cloud.hbmis.domain.PictureData;

@Mapper
public interface IPictureDataDAO {
	@Select("SELECT * FROM t_bas_data_picture WHERE datatime=#{datatime} AND ptid=#{ptid} LIMIT 0,1")
	public PictureData find(@Param("datatime") long datatime, @Param("ptid") String ptid);

	@Select("SELECT * FROM t_bas_data_picture WHERE ptid=#{ptid} AND  datatime BETWEEN #{starttime} AND #{endtime}")
	public List<PictureData> findAll(@Param("ptid") String ptid, @Param("starttime") long starttime,
			@Param("endtime") long endtime);

	@Update("UPDATE t_bas_data_picture SET binarydata=#{data.binarydata},thumbimage=#{data.thumbimage},uploadtime=#{data.uploadtime} WHERE datatime=#{data.datatime} AND picid=#{data.picid}")
	public void update(@Param("data") PictureData data);

	@Insert("INSERT INTO t_bas_data_picture(datatime,uploadtime,ptid,deviceid,binarydata,imagewidth,imageheight,size,thumbimage) VALUES (#{data.datatime},#{data.uploadtime},#{data.ptid},#{data.deviceid},#{data.binarydata},#{data.imagewidth},#{data.imageheight},#{data.size},#{data.thumbimage})")
	public void insert(@Param("data") PictureData data);
}
